/*     */ package com.qmsk.business.store.goodsbom.controller;
/*     */ 
/*     */ import com.qmsk.business.store.goodsbom.dao.GoodsBomDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"goodsBom"})
/*     */ public class GoodsBomController
/*     */ {
/*  41 */   private static final Logger logger = Logger.getLogger(GoodsBomController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GoodsBomDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  51 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  53 */       Map params = new HashMap();
/*  54 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  55 */       MapUtils.addToMap(params, "goodsId", 
/*  56 */         RequestUtils.getLong(request, "goodsId"));
/*  57 */       MapUtils.addToMap(params, "bomGoodsId", 
/*  58 */         RequestUtils.getLong(request, "bomGoodsId"));
/*  59 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  60 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  62 */       logger.error(e);
/*  63 */       ResponseUtils.setErrorMsgResponse(
/*  64 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/goodsId/{goodsId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfGoodsId(HttpServletRequest request, HttpServletResponse response, @PathVariable("goodsId") Long goodsId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*     */     try
/*     */     {
/*  75 */       Map params = new HashMap();
/*  76 */       MapUtils.addToMap(params, "goodsId", goodsId);
/*  77 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  78 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  80 */       logger.error(e);
/*  81 */       ResponseUtils.setErrorMsgResponse(
/*  82 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 100 */       int nResult = 0;
/*     */ 
/* 102 */       String sData = RequestUtils.getStringOfData(request);
/* 103 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 104 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 105 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/*     */ 
/* 108 */       if (nResult > 0)
/* 109 */         DbConnection.commit();
/*     */       else {
/* 111 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 114 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 115 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 116 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 119 */       logger.error(e);
/* 120 */       DbConnection.rollback();
/* 121 */       ResponseUtils.setErrorMsgResponse(
/* 122 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 123 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 141 */       int nResult = 0;
/* 142 */       String sData = RequestUtils.getStringOfData(request);
/* 143 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 144 */       if (p != null) {
/* 145 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 147 */       if (nResult > 0)
/* 148 */         DbConnection.commit();
/*     */       else {
/* 150 */         DbConnection.rollback();
/*     */       }
/* 152 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 153 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 154 */         response);
/*     */     } catch (Exception e) {
/* 156 */       logger.error(e);
/* 157 */       DbConnection.rollback();
/* 158 */       ResponseUtils.setErrorMsgResponse(
/* 159 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 160 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 176 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 178 */       String[] strParams = id.split(",");
/* 179 */       int nResult = this.dao.deleteParams(strParams);
/* 180 */       if (nResult > 0)
/* 181 */         DbConnection.commit();
/*     */       else {
/* 183 */         DbConnection.rollback();
/*     */       }
/* 185 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 186 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 187 */         response);
/*     */     } catch (Exception e) {
/* 189 */       DbConnection.rollback();
/* 190 */       logger.error(e);
/* 191 */       ResponseUtils.setErrorMsgResponse(
/* 192 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 193 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.goodsbom.controller.GoodsBomController
 * JD-Core Version:    0.5.3
 */